home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 1 / ETO Development Tools 1.iso / Essentials / C++ AppleLink Messages / CPlus.Dev$ 2⁄16⁄90 / 0051-Good KeyMap handling-Feb90 next >
Encoding:
Text File  |  1990-02-16  |  720 b   |  25 lines  |  [TEXT/GEOL]

  1. Item    5851103                         13-Feb-90        10:24PST
  2.  
  3. From:   DAWSON.M                        Dawson, Mark
  4.  
  5. To:     CPLUS.DEV$                      C++ Interest List--Developers
  6.  
  7. Sub:    Good KeyMap handling
  8.  
  9. I'm trying to figure out a "good" way of determining if the option key has been
  10. pressed.  In Pascal, you can "optionKeyPressed := theKeyMap[kOptionKey];"
  11. (where kOptionKey = 56 && theKeyMap is of type KeyMap).
  12.  
  13. In C++/C (Events.h), KeyMap is defined as "typedef long KeyMap[4];".
  14.  
  15. The only way I could figure to extract the right field is to:
  16. long *x = theKeyMap;
  17. optionKeyPressed = ((x[kOptionKey/sizeof(long)] >> (kOptionKey%sizeof(long))&1;
  18.  
  19. Is there a cleaner way?
  20.  
  21. Thanks,
  22.  
  23.    Mark
  24.  
  25.